#pragma once

#include <QtCore/QObject>

#include <QtGui/QWidget>
#include <QtGui/QVBoxLayout>
#include <QtGui/QRadioButton>
#include <QtGui/QCheckBox>
#include <QtGui/QGroupBox>
#include <QtGui/QSlider>
#include <QtGui/QButtonGroup>

#include <QtXml/QXmlSimpleReader>
#include <QtXml/QXmlDefaultHandler>
#include <QtXml/QXmlInputSource>

#include <QtCore/QDebug>

#include "Effect.h"
#include "EffectVariable.h"
#include "EffectVariableGuiControl.h"

class EffectLoader : public QObject, public QXmlDefaultHandler
{
Q_OBJECT

public:
	EffectLoader();
	~EffectLoader();

	Effect load(const QString& filename);

	void setupVariableGui(EffectVariable& var, const EffectVariableGuiControlDefinition& def, QVBoxLayout* mainLayout, QObject* obj);

	virtual bool startElement(const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts);
	virtual bool endElement(const QString& namespaceURI, const QString& localName, const QString& qName);
	virtual bool characters(const QString& ch);

private:
	bool m_variablesActive;
	bool m_parsingVariable;
	bool m_parsingGuiControl;

	QString m_name;
	QString m_glslFilename;

	EffectVariable m_currentVariable;
	QList<EffectVariable> m_variables;

	EffectVariableGuiControlDefinition m_currentGuiControlDef;
	std::map<QString, EffectVariableGuiControlDefinition> m_variableGuiControlsDefs;
};
